package com.cuhk.gulimall.product.web;

import com.cuhk.gulimall.product.service.SkuInfoService;
import com.cuhk.gulimall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


@Controller
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;

    @GetMapping(value={"/{skuId}/item.html", "/item.html"})
    public String item(Model model, @PathVariable("skuId") Long skuId) {
        SkuItemVo skuItemVo = skuInfoService.item(skuId);
        model.addAttribute("skuItem", skuItemVo);
        return "item";
    }
}
